# encoding:utf-8

import requests
import base64

'''
菜品识别
'''

def  mydish(img):
    request_url = "https://aip.baidubce.com/rest/2.0/image-classify/v2/dish"
    # 二进制方式打开图片文件
    # f = open('static/images/current.jpg', 'rb')
    # img = base64.b64encode(f.read())

    params = {"image":img,"top_num":5}
    access_token = '24.59b5b3716b1e5b050e998aefadf61767.2592000.1603529392.282335-16179300'
    request_url = request_url + "?access_token=" + access_token
    headers = {'content-type': 'application/x-www-form-urlencoded'}
    response = requests.post(request_url, data=params, headers=headers)
    result = None
    if response:
        print (response.json())
        result = response.json()
        return result


